<?php
/**
 * Created by PhpStorm.
 * User: Inhere
 * Date: 2015/1/29
 * Use : ...
 * File: WebServiceProvider.php
 */

namespace ulue\base\providers;

use ulue\core\ioc\Container;
use ulue\core\ioc\InterfaceServiceProvider;
use ulue\core\router\Uri;
use ulue\core\environment\Environment;

class WebServiceProvider implements InterfaceServiceProvider
{
    public function register(Container $di)
    {
        // Environment
        $di->share('env', function()
        {
            return new Environment;

        })->alias('system.env')->alias('environment')->alias('app.env');

        $di->share('server',  function($di)
        {
            return $di->get('env')->getServer();

        } )->alias('system.server')->alias('app.server');

        $di->share('client', function($di)
        {
            return $di->get('env')->getClient();

        } )->alias('system.client')->alias('app.client');

        // Uri
        $di->share( 'uri', function()
        {
            return new Uri();

        } )->aliases(['url','app.uri', 'app.url', 'system.uri']);
    }
}// end class webServiceProvider